//
//  UIWindow+Extension.m
//  1.28  weibo
//
//  Created by mac on 15/2/3.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "UIWindow+Extension.h"
#import "LWNewfeatureVc.h"
#import "LWWelcomeVc.h"

@implementation UIWindow (Extension)

- (void)chooseViewController{
    //1.从info.plist中获取版本号
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
    //2.从沙盒中取出当前的版本号
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSString *sandBoxVersion = [userDefaults objectForKey:@"CFBundleShortVersionString"];
    //3.比较两个版本的大小
    //获取window
     UIWindow *window = [UIApplication sharedApplication].keyWindow;
    if ([currentVersion compare:sandBoxVersion] == NSOrderedDescending) {
        //显示版本新特性
        LWNewfeatureVc *newView = [[LWNewfeatureVc alloc] init];
        window.rootViewController = newView;
        
        //储存当前的版本号
        [userDefaults setObject:currentVersion forKey:@"CFBundleShortVersionString"];
        [userDefaults synchronize];
    }else{
        LWWelcomeVc *welcomView = [[LWWelcomeVc alloc] init];
        window.rootViewController = welcomView;
    }
}

@end
